import request from '@/utils/request'

//库存管理
const INVENTORY_URL = 'api/admin/inventory'

//添加库存
export const addInventory = (inventory)=>{
    return request.post(INVENTORY_URL,inventory)
}

//修改库存
export const updateInventory = (inventory)=>{
    return request.put(INVENTORY_URL,inventory)
}

//商品批量删除
export const deletes = (ids)=>{
    return request.delete(INVENTORY_URL+"?ids="+ids)
}

//状态修改
export const inventoryStatus = (status,id)=>{
    return request.post(INVENTORY_URL+'/status/'+status+'?id='+id)
}

//库存分页查询,不能根据产品名字查询
export const inventoryPage = (page)=>{
    return request.get(INVENTORY_URL+'/page',{
        params:{
            dateOfManufacture:page.dateOfManufacture,
            page:page.page,
            pageSize:page.pageSize,
            productId:page.productId,
            productNum:page.productNum,
            shelfLife:page.shelfLife,
            storeId:page.storeId
        }
    })
}

//库存分页查询,可以根据产品名字查询
export const inventoryPage2 = (dateOfManufacture,page,pageSize,productName,productNum,shelfLife,storeId,status)=>{
    return request.get(INVENTORY_URL+'/page2?dateOfManufacture='+dateOfManufacture
    +'&page='+page
    +'&pageSize='+pageSize
    +'&productName='+productName
    +'&productNum='+productNum
    +'&shelfLife='+shelfLife
    +'&storeId='+storeId
    +'&status='+status
    // ,{
    //     params:{
    //         dateOfManufacture:dateOfManufacture,
    //         page:page,
    //         pageSize:pageSize,
    //         productName:productName,
    //         productNum:productNum,
    //         shelfLife:shelfLife,
    //         storeId:storeId
    //     }
    // }
)
}

//根据id查询库存
export const inventoryQueryById = (id)=>{
    console.log(id)
    return request.get(INVENTORY_URL+'/'+id)
}